<?php
$nameStr = Yii::t('BWeSport','BookName');
$bookableListStr = Yii::t('BWeSport','Bookable List');
$priceStr = Yii::t('BWeSport','Price_');
$courtTypeStr = Yii::t('BWeSport','Court Type');
$operateStr = Yii::t('BWeSport','Operate');
$editStr = Yii::t('BWeSport','Edit');
$functionListStr = Yii::t('BWeSport','Function list');
$addNewBookStr = Yii::t('BWeSport','Add New Book');
$deleteStr = Yii::t('BWeSport','Delete');
$showBookingAvailableStr = Yii::t('BWeSport','Show BookingAvailable');
?>
<?php
$event = new BWEvent($eventId);
$vender = $event->getMessageManager()->getMessage('vender');
$bookableList = $vender->getMessageManager()->getMessageList();
$app = Blyn::app()->getActiveApp();
?>

<script type="text/javascript">
    $(document).ready(function() {
        $("#selectAll").click(function() {
            if ($(this).attr("checked") == "checked") {
                $(":checkbox").attr("checked", true);
            } else {
                $(":checkbox").attr("checked", false);
            }
        });

    });
</script> 
<script type="text/javascript">
    $(function() {
        $('.tree li:has(ul)').addClass('parent_li').find(' > span').attr('title', 'Collapse this branch');
        $('.tree li.parent_li > span').on('click', function(e) {
            var children = $(this).parent('li.parent_li').find(' > ul > li');
            if (children.is(":visible")) {
                children.hide('fast');
                $(this).attr('title', 'Expand this branch').find(' > i').addClass('icon-plus-sign').removeClass('icon-minus-sign');
            } else {
                children.show('fast');
                $(this).attr('title', 'Collapse this branch').find(' > i').addClass('icon-minus-sign').removeClass('icon-plus-sign');
            }
            e.stopPropagation();
        });
    });</script>
<script type="text/javascript">
    $(function() {
        $("#Event_Shop_CX").click(function() {
            document.getElementById("Event_Shop_CX_View").style.display = '';
            document.getElementById("Event_Clothes_CX_View").style.display = 'none';
        });
        $("#Event_Clothes_CX").click(function() {
            document.getElementById("Event_Shop_CX_View").style.display = 'none';
            document.getElementById("Event_Clothes_CX_View").style.display = '';
        });
    });</script>

<?php
$form = $this->beginWidget('CActiveForm', array(
    "id" => "findBookableForm",
    'enableAjaxValidation' => FALSE,
    'htmlOptions' => array('enctype' => 'multipart/form-data'),
        ));
$model = new BDynamicFormModel();
?>
<legend>
    <h4><?php echo $control->getAjaxLink(array('name' =>$functionListStr, 'id' => 'showEventList')); ?>\  
        <?php echo $bookableListStr;?>
    </h4>
</legend>

<table class="table table-hover">
    <thead>
        <tr>
            <th>
                <input type="checkbox"  id="selectAll"> 
            </th>
            <th><?php echo $nameStr; ?></th>
            <th><?php echo $priceStr; ?></th>
            <th><?php echo $courtTypeStr; ?></th>
            <th><?php echo $operateStr; ?></th>
        </tr> 
    </thead>
    <fieldset>
        <tbody>
            <?php foreach ($bookableList as $bookable) { ?>
                <tr>
                    <td><label class="checkbox">
                            <input type="checkbox" name="checkbox[]" value="<?php echo $bookable->getId(); ?>"> 
                        </label></td>
                    <td> <?php echo $bookable->description; ?> </td>
                    <td> <?php echo $bookable->getMediaManager()->getMedia('price')->getContent();   ?> </td>       
                    <td> <?php echo Yii::t('BWeSport', $bookable->getMediaManager()->getMedia('courtType')->getContent());  ?> </td>       
                    <td>
                        <div class="row-fluid">                         
                            <?php
                            echo $control->getAjaxLink(array('name' =>$editStr, 'id' => 'showAddBookable'), array(
                                'eventId' => $eventId,
                                'bookableId' => $bookable->getId(),
                                //'ajaxContainerId' => 'myModal',
                                'htmlOptions' => array(
                                    'enctype' => 'multipart/form-data'),
                                    //'ajaxOptions' => array(
                                    //'complete' => 'function(){$("#ajax-loaderdiv").hide();$("#myModal").modal("show");}')
                            ));
                            ?> 
                             <?php echo ' | '; ?>
                            <?php
                            echo $control->getAjaxLink(array('name' => '删除', 'id' => 'deleteBookable'), array(
                                'eventId' => $eventId,
                                'bookableId' => $bookable->getId(),
                                'htmlOptions' => array(
                                    'enctype' => 'multipart/form-data')
                            ));
                            ?>  
                        </div>                      
                    </td>
                </tr>
            <?php } ?>
        </tbody>
    </fieldset>
</table>

<div class="row-fluid">
    <?php
    echo $control->getAjaxLink(array('name' =>$addNewBookStr, 'id' => 'showAddBookable'), array(
        'eventId' => $eventId,
        'bookableId' => 0,
        //'ajaxContainerId' => 'myModal',
        'htmlOptions' => array(
            'enctype' => 'multipart/form-data',
            'class' => 'btn'),
            //'ajaxOptions' => array(
            //'complete' => 'function(){$("#ajax-loaderdiv").hide();$("#myModal").modal("show");}')
    ));
    ?>
    <?php
    echo $control->getAjaxLink(array('name' =>$deleteStr, 'id' => 'deleteCheckedBookable'), array(
        'htmlOptions' => array(
            'class' => 'btn',
            'enctype' => 'multipart/form-data'), 'eventId' => $eventId));
    ?>
    <?php
//    echo $control->getAjaxLink(array('name' =>'管理订单', 'id' => 'showManageBookingList'), array(
//        'eventId' => $eventId,
//        'htmlOptions' => array(
//            'class' => 'btn',
//            'enctype' => 'multipart/form-data')));
    ?>
</div>   

<div><input type="hidden" name="curPageNo" value="1"></div>

<div class="pagination">  
    <ul>  
        <li class="active">
            <a href="javascript:void()">前一页</a>    </li>  
        <li class="active">
            <a href="javascript:void()">1</a>    </li>  
        <li class="active">
            <a href="javascript:void()">后一页</a>    </li>  
    </ul>  
</div>
<?php $this->endWidget(); ?>


